package interfacegraphique;

import bbqtorrent.Torrent;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import tools.Format;

/**
 *
 * @author CYRIL
 */
public class FenetreProperty extends JFrame{

    private JLabel titre;
    private JLabel description;
    private JLabel destination;
    private JLabel size;
    private JButton ok;
    private JPanel conteneur;

    
    public FenetreProperty(Torrent t){

        this.titre = new JLabel("Nom : "+t.getName());
        this.description = new JLabel("Commentaire : "+t.getComment());
        this.destination = new JLabel("Destination : ");
        this.size = new JLabel("Size : "+Format.bytes(t.getLength()));
        this.ok = new JButton("OK");
        this.conteneur = new JPanel();

        this.ok.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                FenetreProperty.this.dispose();
            }
        });

        this.ok.setPreferredSize(new Dimension(40, 20));
        this.conteneur.setLayout(new GridLayout(5, 1));
        this.conteneur.add(titre);
        this.conteneur.add(description);
        this.conteneur.add(destination);
        this.conteneur.add(size);
        

        this.add(this.conteneur, BorderLayout.CENTER);
        this.add(ok, BorderLayout.SOUTH);
        this.pack();
        this.setSize(200, 200);
        this.setVisible(true);

    }
}
